export const BASE_URL = "http://slcs.zhiyun199.net"

/**
 * 
 * @param {string} method 
 * @param {string} url 
 * @param {object} data 
 * @returns {Promise}
 */
const fetch = (method, url, data = {}) => uni.request({
	method,
	url: BASE_URL + url,
	header: {
		"Authorization": "Bearer " + uni.$store.state.token || ""
	},
	data
})
/**
 * 
 * @param {string} url 
 * @returns 
 */
const get = (url) => fetch("get", url)
/**
 * 
 * @param {string} url 
 * @param {object} data 
 * @returns 
 */
const post = (url, data) => fetch("post", url, data)

const request = {
	get,
	post
}

export default request